#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
	int ret = 0;
	int n, st;
	cin >> n >> st;
	int now = st;
	
	for(int i = 1; i <= n; i ++ ) {
		int x;
		cin >> x;
		if(now == 0) {
			break;
		} 
		if(now > 0) {
			now -= x;
		} else {
			now += x;
		}
		ret += x;
	}
	cout << ret << endl;
	return 0;
}

